package com.prinxchengshan.reportbase.Utils;

import java.util.Calendar;
import java.util.Date;

public class DateUtil {
    public String getToday() {
        Date zdate1 = new Date();

        Calendar rightNow = Calendar.getInstance();
        rightNow.setTime(zdate1);
        rightNow.add(Calendar.HOUR, -1);
        Date zdate = rightNow.getTime();


        int year = zdate.getYear()+ 1900;
        int month = zdate.getMonth() + 1;
        int date = zdate.getDate();
        String str_month;
        String str_date;
        if (month < 10){
            str_month = "" + 0 + month;
        }else {
            str_month = "" + month;
        }

        if (date < 10){
            str_date = "" + 0 + date;
        }else {
            str_date = "" + date;
        }
        String udate = "" + year + str_month + str_date;
        return udate;
    }

    public String getTimeStr(){
        Date date1 = new Date();
        Calendar rightNow = Calendar.getInstance();
        rightNow.setTime(date1);
        rightNow.add(Calendar.HOUR, -1);
        Date date = rightNow.getTime();


        int hours = date.getHours();
        int minutes = date.getMinutes();
        int seconds = date.getSeconds();


        String str_h;
        String str_m;
        String str_s;
        if (hours < 10){
            str_h = "" + 0 + hours;
        }else{
            str_h = "" + hours;
        }

        if (minutes < 10){
            str_m = "" + 0 + minutes;
        }else {
            str_m = "" + minutes;
        }

        if (seconds < 10){
            str_s = "" + 0 + seconds;
        }else{
            str_s = "" + seconds;
        }
        String ztime = str_h + str_m + str_s;
        return ztime;
    }

}
